package com.test.restruant.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.test.restruant.pojo.DishTable;
import com.test.restruant.service.DishTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("table.html")
public class TableController {
    //@Autowired
    @Reference
    private DishTableService dishTableService;//这个地方的红线不用管

    @RequestMapping(params = "act=list")
    public String list(String name, Model model) {
        List<DishTable> tables=dishTableService.getTableList(name);
        model.addAttribute("tables",tables);
        return "table_list";
    }

    @RequestMapping(params = "act=go_edit")
    public String goEdit() {
        return "table_edit";
    }

    @RequestMapping(params = "act=edit")
    public String edit(DishTable dishTable){
        dishTableService.insert(dishTable);
        return "forward:table.html?act=list";
    }
}
